#include "ResponseCmd.h"
#include "Main/GateWay.h"
ResponseCmd::ResponseCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
    m_responseCode = 0;
}

Package ResponseCmd::toPackage()
{
    Package package;
    QByteArray body;
    body.append(DataTypeConver::intToByteArray(m_responseCode,2));
 //   body = encrypt(body,KeyType::AES);

    package.setId(m_cmdId);
    package.setFunction(FunctionCode);
    package.setBody(body);

    return package;
}

void ResponseCmd::unPackage(Package package)
{

    m_cmdId = package.id();
    QByteArray body;
    body=package.body();
  //  body = decrypt(package.body(),KeyType::AES);
    m_responseCode = body.mid(0,2).toHex().toInt(0,16);

}
quint16 ResponseCmd::responseCode() const
{
    return m_responseCode;
}

void ResponseCmd::setResponseCode(const quint16 &responseCode)
{
    m_responseCode = responseCode;
}

